package com.ruoyi.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.*;

@Getter
@AllArgsConstructor
public enum JobTypeEnum {

    UNKNOWN(0, "未知"),

    HOISTING_SECURITY_JOB_BILL(1, "吊装安全作业票"),

    HOT_WORK_SECURITY_JOB_BILL(2, "动火安全作业票"),

    GROUNDBREAKING_SECURITY_JOB_BILL(3, "动土安全作业票"),

    RADIAL_SECURITY_JOB_BILL(4, "动用射线安全作业票"),

    OPEN_CIRCUIT_SECURITY_JOB_BILL(5, "断路安全作业票"),

    HIGH_SECURITY_JOB_BILL(6, "高处安全作业票"),

    TEMPORARY_ELECTRIC_SECURITY_JOB_BILL(7, "临时用电安全作业票"),

    BLIND_PLATE_SECURITY_JOB_BILL(8, "盲板抽堵安全作业票"),

    OPENING_SECURITY_JOB_BILL(9, "设备开人孔安全作业票"),

    LIMITED_SECURITY_JOB_BILL(10, "受限空间安全作业票"),
    ;

    private final Integer code;
    private final String desc;

    public static JobTypeEnum valueOfCode(Integer code) {
        return Arrays.stream(values()).filter(status -> status.getCode().equals(code)).findFirst().orElse(UNKNOWN);
    }

    public static List<HashMap<String, Object>> getAllList() {
        List<HashMap<String, Object>> list = new ArrayList<>();
        for (JobTypeEnum jobTypeEnum : EnumSet.allOf(JobTypeEnum.class)) {
            HashMap<String, Object> map = new HashMap<>();
            map.put("name", jobTypeEnum.desc);
            map.put("code", jobTypeEnum.code);
            list.add(map);
        }
        return list;
    }

}
